<?php

     if(!$cboTitle) {
         array_push($ActionResults, "Please enter Title.");
         $intFailed++;
     }

//FirstName
     if(!$txtFirstName) {
         array_push($ActionResults, "Please enter First Name.");
         $intFailed++;
     }else{
         $txtFirstName = ucwords(strtolower($txtFirstName)); 
     }

//Surname
     if(!$txtSurname) {
         array_push($ActionResults, "Please enter Surname.");
         $intFailed++;
     }else{
         $txtSurname = ucwords(strtolower($txtSurname)); 
     }

//Address1
     if(!$txtAddress1) {
         array_push($ActionResults, "Please enter Address.");
         $intFailed++;
     }else{
         $txtAddress1 = ucwords(strtolower($txtAddress1)); 
     }

//Password
     if(!$txtPassword) {
         array_push($ActionResults, "Please enter Password.");
         $intFailed++;
     }

     if($intFailed > 0){
         return(FALSE);
     }

     if ($intStaffID){
        $strSQL = "Update tblStaff
                     SET   tblStaff.Title =  '$cboTitle'
                         , tblStaff.FirstName =  '$txtFirstName'
                         , tblStaff.Surname =  '$txtSurname'
                         , tblStaff.Address1 =  '$txtAddress1'
                         , tblStaff.Address2 =  '$txtAddress2'
                         , tblStaff.City =  '$txtCity'
                         , tblStaff.PostalCode =  '$txtPostalCode'
                         , tblStaff.Country =  '$cboCountry'
                         , tblStaff.Phone =  '$txtPhone'
                         , tblStaff.Email =  '$txtEmail'
                         , tblStaff.Fax =  '$txtFax'
                         , tblStaff.Password =  password('$txtPassword')
     "; 
        $strJoin = " WHERE ";
        $strSQL .= $strJoin."tblStaff.ID =  '$intStaffID'";
        $strMessage = " Updated";
    }Else{

        $strSQL = "INSERT INTO tblStaff
                     (     tblStaff.Title
                         , tblStaff.FirstName
                         , tblStaff.Surname
                         , tblStaff.Address1
                         , tblStaff.Address2
                         , tblStaff.City
                         , tblStaff.PostalCode
                         , tblStaff.Country
                         , tblStaff.Phone
                         , tblStaff.Email
                         , tblStaff.Fax
                         , tblStaff.Password
                     )Values( '$cboTitle'
                         , '$txtFirstName'
                         , '$txtSurname'
                         , '$txtAddress1'
                         , '$txtAddress2'
                         , '$txtCity'
                         , '$txtPostalCode'
                         , '$cboCountry'
                         , '$txtPhone'
                         , '$txtEmail'
                         , '$txtFax'
                         , password('$txtPassword')
                       )";
        $strMessage = "added";
    }
    $strSQL .= ";";

         if (!include (MODULE . "/action/actMySqlResults")){
             array_push($ActionResults,"Failed To Add Staff To Database");
             return(false);
         }
?>
